﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace StarLabel.label.item
{
    /// <summary>
    /// Copyright 2019  ZhengJi. All Rights Reserved.
    /// 二维码
    /// </summary>
    public class Bar2DItem : Item
    {
        
        public string ECCLevel { get; set; }
        public string CellWidth { get; set; }
        

        public string Mode { get; set; }

        public string Model { get; set; }

        public string Mask { get; set; }
        public Bar2DItem(XmlElement el) : base(el)
        {
        }

        protected override void parseFromXml()
        {

             
            this.ECCLevel = this.xmlEl.Attributes["ECCLevel"] == null ? "Q" : this.xmlEl.Attributes["ECCLevel"].Value;
            this.CellWidth = this.xmlEl.Attributes["CellWidth"] == null ? "5" : this.xmlEl.Attributes["CellWidth"].Value;
            this.Mode = this.xmlEl.Attributes["Mode"] == null ? "A" : this.xmlEl.Attributes["Mode"].Value;
            this.Model = this.xmlEl.Attributes["Model"] == null ? "M2" : this.xmlEl.Attributes["Model"].Value;
            this.Mask = this.xmlEl.Attributes["Mask"] == null ? "S7" : this.xmlEl.Attributes["Mask"].Value;

            base.parseFromXml();
        }

        public override void DrawLabel(float x, float y, string labelText, string rotation)
        {
            rotation = string.IsNullOrEmpty(rotation) ? this.Rotation : rotation;

            TSCPrint.QRCode(x, y, this.ECCLevel, this.CellWidth, this.Mode, rotation, this.Model, this.Mask, labelText);
        }

    }
}
